package com.yungu.swift.system.sys.service.impl;

import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.system.sys.dao.SysWayCalculationMapper;
import com.yungu.swift.system.sys.model.dto.SysWayCalculationDto;
import com.yungu.swift.system.sys.service.SysWayCalculationService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;


/**
 * SystemWayCalculationServiceImpl
 **/

@Service
public class SysWayCalculationServiceImpl implements SysWayCalculationService {
    @Autowired
    private SysWayCalculationMapper<SysWayCalculationDto> systemWayCalculationMapper;

    @Override
    public ResponseData<PageList<SysWayCalculationDto>> queryPage(Map<String, Object> params, int pageNum, int pageSize) {
        PageBounds pageBounds = new PageBounds(pageNum, pageSize);
        return ResponseData.buildSuccessResponse(systemWayCalculationMapper.queryPage(params, pageBounds));
    }

    @Override
    public ResponseData<SysWayCalculationDto> findOne(Map<String, Object> params) {
        List<SysWayCalculationDto> list = systemWayCalculationMapper.list(params);
        if (list != null && list.size() > 0) {
            return ResponseData.buildSuccessResponse(list.get(0));
        }
        return ResponseData.buildErrorResponse(ResponseData.ERROR_CODE, "查无符合条件");
    }
}